/*
 * AS3 MultiTouch Client
 *
 * DragBehaviour - Moves the object to the cursor position  
 *
 * Copyright 2008 Artifacts - Fine Software Development
 * http://www.artifacts.de
 * Author: Michael Markowski (m.markowski@artifacts.de)
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 */

/**
 * DragBehaviour - Moves the object to the cursor position 
 * Uses caurina tweener for moving.  
 */
package de.artifacts.multitouch.behaviours
{
	import de.artifacts.multitouch.TouchEvent;
	import de.artifacts.multitouch.Cursor;
	import de.artifacts.multitouch.TouchManager;
	import caurina.transitions.Tweener;
	
	public class DragBehaviour extends TouchBehaviour
	{		
		public function DragBehaviour()
		{
			super();
		}
		override public function repositionedHandler(event : TouchEvent) : void
		{			
			if (event.cursor==null) return;
			if (!touchManager.isExclusiveTouch(touchable, event.cursor)) return;
			if (event.cursor.touchables.indexOf(touchable)>-1)
			{
				var x : int = event.cursor.position.x - touchable.offsetX;
				var y : int = event.cursor.position.y - touchable.offsetY;
				touchable.wrappee.x = x;
				touchable.wrappee.y = y;							
			}
		}		
		
		override public function touchedHandler(event : TouchEvent) : void
		{		
			// trace("touched");	
		}
				
	}
}